package com.generator;

import com.generator.config.AbstractDbConfig;
import com.generator.mybaitsPlus.MpAutoGeneratorImpl;
import com.generator.mybaitsPlus.MpConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 大忽悠
 * @create 2022/9/15 9:53
 */
@Configuration
@EnableConfigurationProperties(MpConfig.class)
public class AutoGeneratorAutoConfiguration {

     @Bean
     @ConditionalOnProperty(prefix = "spring.datasource", name = "autoGenerator.open", havingValue = "true")
     public AutoGenerator autoGenerator(AbstractDbConfig dbConfig){
         return new MpAutoGeneratorImpl(dbConfig);
     }
}
